package com.ruoyi.demo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.demo.domain.AuctionSessionGoods;
import com.ruoyi.demo.service.IAuctionSessionGoodsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 专场商品关联Controller
 *
 * @author metaee
 * @date 2025-03-06
 */
@Api(tags = "专场商品关联管理")
@RestController
@RequestMapping("/demo/sessionGoods")
public class AuctionSessionGoodsController extends BaseController
{
    @Autowired
    private IAuctionSessionGoodsService auctionSessionGoodsService;

    /**
     * 查询专场商品关联列表
     */
    @ApiOperation("查询专场商品关联列表")
    @PreAuthorize("@ss.hasPermi('demo:sessionGoods:list')")
    @GetMapping("/list")
    public TableDataInfo list(AuctionSessionGoods auctionSessionGoods)
    {
        startPage();
        List<AuctionSessionGoods> list = auctionSessionGoodsService.selectAuctionSessionGoodsList(auctionSessionGoods);
        return getDataTable(list);
    }

    /**
     * 导出专场商品关联列表
     */
    @ApiOperation("导出专场商品关联列表")
    @PreAuthorize("@ss.hasPermi('demo:sessionGoods:export')")
    @Log(title = "专场商品关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AuctionSessionGoods auctionSessionGoods)
    {
        List<AuctionSessionGoods> list = auctionSessionGoodsService.selectAuctionSessionGoodsList(auctionSessionGoods);
        ExcelUtil<AuctionSessionGoods> util = new ExcelUtil<AuctionSessionGoods>(AuctionSessionGoods.class);
        util.exportExcel(response, list, "专场商品关联数据");
    }

    /**
     * 获取专场商品关联详细信息
     */
    @ApiOperation("获取专场商品关联详细信息")
    @PreAuthorize("@ss.hasPermi('demo:sessionGoods:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@ApiParam(value = "专场商品关联ID", required = true) @PathVariable("id") Long id)
    {
        return success(auctionSessionGoodsService.selectAuctionSessionGoodsById(id));
    }

    /**
     * 新增专场商品关联
     */
    @ApiOperation("新增专场商品关联")
    @PreAuthorize("@ss.hasPermi('demo:sessionGoods:add')")
    @Log(title = "专场商品关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuctionSessionGoods auctionSessionGoods)
    {
        return toAjax(auctionSessionGoodsService.insertAuctionSessionGoods(auctionSessionGoods));
    }

    /**
     * 修改专场商品关联
     */
    @ApiOperation("修改专场商品关联")
    @PreAuthorize("@ss.hasPermi('demo:sessionGoods:edit')")
    @Log(title = "专场商品关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuctionSessionGoods auctionSessionGoods)
    {
        return toAjax(auctionSessionGoodsService.updateAuctionSessionGoods(auctionSessionGoods));
    }

    /**
     * 删除专场商品关联
     */
    @ApiOperation("删除专场商品关联")
    @PreAuthorize("@ss.hasPermi('demo:sessionGoods:remove')")
    @Log(title = "专场商品关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@ApiParam(value = "专场商品关联ID数组", required = true) @PathVariable Long[] ids)
    {
        return toAjax(auctionSessionGoodsService.deleteAuctionSessionGoodsByIds(ids));
    }
}
